/**
 * @FileDescription: useLoading
 * @Author: kahu
 * @Date: 2023/6/12
 * @LastEditors: kahu
 * @LastEditTime: 2023/6/12
 */
import { ElLoading } from 'element-plus'
export function useLoading(){
  let loading;
  function showLoading(){
    if(loading) return
    loading = ElLoading.service({
      lock: true, // 是否锁屏
      target: '.sub-main', // 需要遮罩的区域
      body: true,
      background: '#ffffff',
      customClass: 'mask' // 遮罩层新增类名
    })
  }

  function closeLoading(){
    if (loading)loading.close()
  }
  return {
    loading,
    showLoading,
    closeLoading
  }
}
